package com.l024.loanthief.help;

import android.app.Activity;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.l024.loanthief.R;

/**
 * @author wu_ming_zhi_bei
 * @date 2021/1/20 10:24
 * @Notes
 */
public class GlideHelp {
    private static GlideHelp glideHelp;

    private GlideHelp() {
    }

    public static GlideHelp getInstance(){
        if(glideHelp==null){
            synchronized (GlideHelp.class){
                if(glideHelp==null){
                    glideHelp = new GlideHelp();
                }
            }
        }
        return glideHelp;
    }

    public void setImg(Activity activity,String path,ImageView imageView){
        Glide.with(activity)
                .load(path)
                .placeholder(R.drawable.chat_load_icon)
                .error(R.drawable.chat_error_icon)
                .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭Glide的硬盘缓存机制
                .into(imageView);
    }

    public void setImg(Activity activity,int path,ImageView imageView){
        Glide.with(activity)
                .load(path)
                .placeholder(R.drawable.chat_load_icon)
                .error(R.drawable.chat_error_icon)
                .diskCacheStrategy(DiskCacheStrategy.NONE)//关闭Glide的硬盘缓存机制
                .into(imageView);
    }
}
